#include "uhm/common.hxx"
#include "uhm/util.hxx"

#include "uhm/discrete/base.hxx"

#include "uhm/discrete/extension/metis.hxx"


#define N 1

using namespace uhm;

typedef ID_Node_<N>            Id_Nd;
typedef ID_Element_<N>         Id_El;
typedef Int_                   Uhm;

typedef Mesh_<Id_Nd,Id_El,Uhm> Mesh;

int main (int argc, char **argv) {

  Mesh::_Id_El_ el;
  Mesh::_Id_Nd_ nd;

  Mesh mesh;
  Mesh::Node_* n;
  Mesh::Element_* e;

  std::vector< Mesh::Element_* > els;
  std::vector<Int_> xadj, adjncy, adjwgt;
  Int_ pid = 0;

  el.set_id(0, 10); e = mesh.add_element(el); els.push_back(e); 
  e->push_begin();
  nd.set_id(0, 0); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 1); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 2); n = mesh.add_node(nd); e->push(n);
  e->push_end();
  
  el.set_id(0, 20); e = mesh.add_element(el); els.push_back(e); 
  e->push_begin();
  nd.set_id(0, 2); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 3); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 4); n = mesh.add_node(nd); e->push(n);
  e->push_end();

  el.set_id(0, 30); e = mesh.add_element(el); els.push_back(e); 
  e->push_begin();
  nd.set_id(0, 3); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 4); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 5); n = mesh.add_node(nd); e->push(n);
  e->push_end();

  std::cout << mesh << std::endl;
  elements2graph<Mesh>(&els, &xadj, &adjncy, &adjwgt, pid);

  graph_show(std::cout, xadj, adjncy, adjwgt);

  return true;
}


